/**
 *
 * COOKIE存储
 * @param {String} key
 * @param {Object} val
 * @param {number} [time=10]
 */
function setcookie(key, val, time = 10) {
  if (typeof val == 'object') {
    val = JSON.stringify(val)
  }
  const t = new Date
  t.setTime(t.getTime() - 1000 * 60 * 60 * 8 + 1000 * time)
  document.cookie = `${key}=${val}; expires=${t}`
}
/**
 * COOKIE获取
 * @param {String} key
 * @return String 
 */
function getcookie(key) {
  let arr = document.cookie.split('; ')
  for (let i = 0; i < arr.length; i++) {
    let item = arr[i]
    let tempArr = item.split('=')
    if (key == tempArr[0]) {
      return tempArr[1]
    }
  }
  /* arr.forEach(item => {
    let tempArr = item.split('=')
    if (tempArr[0] == key) {
      return tempArr[1]
    }
  }) */
}
/**
 *
 * COOKIE删除
 * @param {String} key
 */
function removecookie(key) {
  setcookie(key, null, -1)
}